package easy;

import java.util.HashSet;
import java.util.Set;

public class Solution_263 {

    public static boolean isUgly(int num) {
//        if (num == -2147483648) return false;
//        num = Math.abs(num);
        // 思路过于复杂，傻屌
        for (int i = 2; i*i <= num;) {
            int mod = num % i;
            int temp = num / i;
            if (mod !=0) {
                int step = (mod+i)/(temp-1);
                System.out.println(step);
                i = i + Math.max(1, step);
                continue;
            }
            num = temp;
            if (i!=2 && i!=3 && i!=5) {
                return false;
            }
        }
        if (num==1 || num==2 || num==3 || num==5) {
            return true;
        }
        return false;
    }

    public static void main(String[] args) {
        System.out.println(isUgly(9));
    }
}
